using ASP;
using HoWave.Common;
using HoWave.Data.Bll;
using HoWave.Web.Admin;
using System;
using System.Data;
using System.Drawing;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Admin_Admin_JXC_AccountSubjectTV : Admin, IRequiresSessionState
{
	protected HtmlHead Head1;
	protected HiddenField hfParentID;
	protected TreeView TVAccountSubject;
	protected HtmlForm asform;
	private AccountSubject bllAccountSubject;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	public AccountSubject BllAccountSubject
	{
		get
		{
			if (this.bllAccountSubject == null)
			{
				this.bllAccountSubject = new AccountSubject();
			}
			return this.bllAccountSubject;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			if (!base.admin.CheckAdminPower(46))
			{
				base.WriteLog("Modidy", Language.GetAdminMsg("Log/Access", "0"), "Admin_Admin_JXC_AccountSubjectTV");
				base.WriteRightErrMsg();
			}
			this.hfParentID.Value = Fetch.Get("DefaultValue");
			this.TreeViewClassBind();
		}
	}
	public void TreeViewClassBind()
	{
		this.TVAccountSubject.Nodes.Clear();
		TreeNode treeNode = new TreeNode();
		treeNode.Text = "<a  style=\"cursor:pointer\" id='node0' onclick='javascript:window.returnValue=0;window.close();'>会计科目</a>";
		treeNode.Value = "0";
		treeNode.ImageUrl = "~/Admin/Images/base.gif";
		this.TVAccountSubject.Nodes.Add(treeNode);
		if (this.hfParentID.Value == "0")
		{
			treeNode.Selected = true;
			this.TVAccountSubject.SelectedNodeStyle.BackColor = Color.Silver;
		}
		DataTable dataTable = this.BllAccountSubject.GetList("AccountSParentID=0").Tables[0];
		if (dataTable.Rows.Count != 0)
		{
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				TreeNode treeNode2 = new TreeNode();
				string text = dataTable.Rows[i]["AccountSName"].ToString();
				string text2 = dataTable.Rows[i]["AccountSubjectID"].ToString();
				string text3 = string.Concat(new string[]
				{
					"<a  style=\"cursor:pointer\" id='node",
					text2,
					"'onclick='javascript:window.returnValue=",
					text2,
					";window.close();'>",
					text,
					"</a>"
				});
				treeNode2.Text = text3;
				treeNode2.Value = text2;
				treeNode2.ImageUrl = "~/Admin/Images/folder_icon.gif";
				this.TVAccountSubject.Nodes.Add(treeNode2);
				this.ChildNode(treeNode2, treeNode2.Value);
			}
		}
	}
	private void ChildNode(TreeNode node, string fid)
	{
		if (this.hfParentID.Value == fid)
		{
			node.Selected = true;
			this.TVAccountSubject.SelectedNodeStyle.BackColor = Color.Silver;
		}
		DataTable dataTable = this.BllAccountSubject.GetList("AccountSParentID=" + fid).Tables[0];
		if (dataTable.Rows.Count != 0)
		{
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				TreeNode treeNode = new TreeNode();
				string text = dataTable.Rows[i]["AccountSName"].ToString();
				string text2 = dataTable.Rows[i]["AccountSubjectID"].ToString();
				string text3 = string.Concat(new string[]
				{
					"<a  style=\"cursor:pointer\" id='node",
					text2,
					"'onclick='javascript:window.returnValue=",
					text2,
					";window.close();'>",
					text,
					"</a>"
				});
				treeNode.Text = text3;
				treeNode.Value = text2;
				node.ChildNodes.Add(treeNode);
				this.ChildNode(treeNode, treeNode.Value);
			}
		}
	}
}
